#include<stdio.h>
#include<fstream>
using namespace std;
#include <math.h>
double fact(int c);
double comb(int i, int j);
int main()
{
	ofstream output("output.txt");
	int n, q, d, M, t, c, f;
	for (q = 2;q<6;q++)
	{
		for (n = 2;n<10;n++)
		{
			for (t = 1;t<6;t++)
			{
				int i, f;
				int s = 0;
				for (i = 0;i <= t;i++)
				{
					if (n>i)
					{
						f = comb(n, i);
					}
					s = s + f*pow(q - 1, i);
				}
				M = pow(q, n) / s;
				d = 2 * t + 1;
				output << q << ' ' << n << ' ' << d << ' ' << ' ' << "Hamming Bound " << M << endl;
				printf("q=%2d,n=%2d,d=%2d,Hamming bound is %2d\n", q, n, d, M);
			}
		}
	}
	output.close();
	system("pause");
	return 0;
}
double fact(int c)
{
	int i;
	double product;
	product = 1;
	for (i = 1;i <= c;i++)
	{
		product = product*i;
	}
	return product;
}

double comb(int k, int j)
{
	int com;
	com = comb(k, j);
	com = fact(k) / (fact(k - j)*fact(j));
	return com;

}
